<template>
  <div v-if="detailVisible">
    <!--    <form-create :option="detailData.option" :rule="detailData.rule" />-->

    <form-create
      :rule="detailData.rule"
      :option="detailData.options"
      v-model="detailData.formData"
    />
  </div>
</template>

<script lang="ts" setup>
import { FormDataApi } from '@/api/res/FormData'
import { GetFromDataVo } from '@/api/res/FormData/vo/GetFormDataVo'
import { setConfAndFields2 } from '@/utils/formCreate'

const detailVisible = ref(false)
const detailData = ref({
  options: {},
  rule: [],
  formData: {}
})
const props = defineProps<{
  formDataVo: GetFromDataVo
}>()

const openDetail = async () => {
  // 设置表单

  const formDataReq = {
    Form_data: {
      id: props.formDataVo.formDataId,
      '@column': 'id,content,app_dsgn_id,form_dsgn_id,form_type'
    },
    Form_dsgn: {
      id: props.formDataVo.formDsgnId,
      '@column': 'content'
    }
  }
  const data = await FormDataApi.getFormListPage(formDataReq)

  const formDsgn = data.Form_dsgn.content
  detailData.value.rule = formDsgn.widgetList
  formDsgn.formConfig.submitBtn = false
  detailData.value.options = formDsgn.formConfig
  detailData.value.formData = data.Form_data.content
  // 弹窗打开
  detailVisible.value = true
}

onMounted(() => {
  openDetail()
})

</script>
